/*
 
 RFA Manager, Refractor2 Archive editor.
 Copyright (C) 2008
 Torsten Kammer         torsten@ferroequinologist.de
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */

#import <Cocoa/Cocoa.h>

@class RFATreeNode;
@class RFAArchive;
@class RFADragAndDropDelegate;

@interface MyDocument : NSDocument
{
    RFAArchive *archive;
    RFADragAndDropDelegate *outlineViewDelegate;
    
    IBOutlet NSBrowser *browser;
	IBOutlet NSOutlineView *outlineView;
	IBOutlet NSTableView *searchView;
	
    IBOutlet NSSearchField *search;
    IBOutlet NSSegmentedControl *viewModeControl;
    IBOutlet NSPathControl *searchPathControl;
    IBOutlet NSArrayController *searchArrayController;
	IBOutlet NSTreeController *fileTreeController;
	IBOutlet NSTextField *statusBar;
    
    BOOL inSearchMode;
    NSUInteger viewMode;
	
	BOOL canRunFile;
	NSString *mapName;
	NSString *modName;
	NSString *gamePath;
	
	NSArray *foundEntries;
	
	// Adding files
	NSUInteger newFileIndex;
	NSArray *filesToInsert;
	RFATreeNode *nodeToInsertTo;
	BOOL replaceAll;
	BOOL leaveAll;
	BOOL replaceFirst;
}

- (IBAction)run:(id)sender;
- (IBAction)saveAndRun:(id)sender;

- (IBAction)selectDisplayMode:(id)sender;
- (IBAction)search:(id)sender;
- (IBAction)cancelSearch:(id)sender;

@property (assign) NSUInteger viewMode;
@property (assign) NSBrowser *browser;
@property (assign) NSOutlineView *outlineView;
@property (assign) NSTableView *searchView;
@property (assign) NSArrayController *searchArrayController;
@property (assign) NSPathControl *searchPathControl;

@property (readonly) NSInteger tabToShow;

@property (readonly) NSArray *foundEntries;
@property (readonly) RFAArchive *archive;

@property (readonly) BOOL saveAndRunEnabled;
@property (readonly) BOOL canExtract;
@property (readonly) BOOL canDelete;
@property (readonly) BOOL canAddFiles;
@property (readonly) BOOL canMakeNewFolder;

// Methods that get called from the menu.
- (IBAction)createNewFolder:(id)sender;
- (IBAction)deleteItems:(id)sender;
- (IBAction)addFiles:(id)sender;
- (IBAction)extractFiles:(id)sender;

// These methods have all the bells and whistles you'd expect, mainly including dialogues that warn before a file gets overwritten. For this reason, they should be used whenever a file copy/move is initiated by the user.
- (void)startAddingFilesWithNames:(NSArray *)names toNode:(RFATreeNode *)node atIndex:(NSUInteger)index;
- (void)startCoypingNodes:(NSArray *)nodes toNode:(RFATreeNode *)node atIndex:(NSUInteger)index;
- (void)startMovingNodes:(NSArray *)nodes toNode:(RFATreeNode *)node atIndex:(NSUInteger)index;

// Creates files at a given location and returns the corresponding names. It'll overwrite without asking at the moment.
- (NSArray *)namesForFiles:(NSArray *)files createdAt:(NSString *)path;

- (void)updateSearchPredicate;

@end
